package com.kust.smarthome.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kust.smarthome.web.dto.PersonDetailsDto;
import com.kust.smarthome.web.model.PersonDetails;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author iAuzre
 * @since 2021-07-06
 */
@Repository
public interface PersonDetailsMapper extends BaseMapper<PersonDetails> {

    /*relationTypeId logoId personName personBirth personSex height weight rateNow safeDistance*/

    @Select("select r.relation_id as relationTypeId," +
            "p.logo_id as logoId,p.person_name as personName," +
            "p.person_birth as pp.weight as weight,p.rate_now as rateNow," +
            "p.safe_distance as safeDistance " +
            "from person_details p " +
            "left join relation r on p.user_id=r.user_id " +
            "where p.user_id=#{userId}")
    List<PersonDetails> selectPersonDetailsByUser(Integer userId);
}
